/*
 * @Author: your name
 * @Date: 2021-06-07 12:59:40
 * @LastEditTime: 2021-06-15 10:58:08
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \UDP\CLIENT_\user.cpp
 */
#include "user.h"

User::~User()
{
    //不实现
}

void User::set_Name(const string& name)
{
	this->m_Username = name;
}

void User::set_Passwd(const string& passwd)
{
	this->m_Password = passwd;
}

void User::set_Type(int type)
{
	this->m_type = type;
}

void User::set_Balance(double balance)
{
	if (balance < 0 || balance > 99999)
	{
		cout << "设置用户余额出错" << endl;
		exit(-1);
	}
	this->m_Balance = balance;
}

void User::set_Commodity_Num(int commodity_num)
{
    if(commodity_num > MAX_CART_COMMODITY_NUM)
    {
        cout << "购物车已满，请清理后再添加购物车" << endl;
    }
    else
    {
        this->m_commodity_num = commodity_num;
    }
}

void User::set_Commodity_Index_Array(int* array,int length)
{
	for(int i=0; i<length; i++)
	{
		this->commodity_index_array[i] = array[i];
	}
}

void User::set_Commodity_Index_Num_Array(int* array,int length)
{
	for(int i=0; i<length; i++)
	{
		this->commodity_index_num_array[i] = array[i];
	}
}


string User::get_Name()
{
	return this->m_Username;
}

string User::get_Passwd()
{
	return this->m_Password;
}

int User::get_Type()
{
	return this->m_type;
}

double User::get_Balance()
{
	return this->m_Balance;
}

int User::get_Commodity_Num()
{
    return this->m_commodity_num;
}

int* User::get_Commodity_Index_Array()
{
	return this->commodity_index_array;
}

int* User::get_Commodity_Index_Num_Array()
{
	return this->commodity_index_num_array;
}